﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using xTeam.HengLe.Entity;
using xTeam.Hengle.DataAccess;
using xTeam.HengLe.Helper;

namespace xTeam.HengLe.Controller.Manage
{
    [Authorize]
    public class ClassifyController : BaseController
    {
        public ClassifyController()
        {
            _classifyDataAccess = new ClassifyDataAccess(_connectionString);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(string moduleKey)
        {
            ViewData["moduleKey"] = moduleKey;
            List<EClassify> classifyList = _classifyDataAccess.GetClassLisytByModuleKey(moduleKey, 0);
            return View("Classify", classifyList);
        }
        /// <summary>
        /// 
        /// </summary
        public ActionResult Classify(int classifyId = 0, string moduleKey = "")
        {
            EClassify classify =
                _classifyDataAccess.GetClassifyById(classifyId)
                ?? new EClassify() { ModuleKey = moduleKey };
            List<EClassify> classifyList = _classifyDataAccess.GetClassLisytByModuleKey(moduleKey, 0);
            ViewData["ClassifyList"] = classifyList;
            //this.ModelState.Remove("ParentId");
            return View("Post", classify);
        }
        /// <summary>
        /// 
        /// </summary>
        public ActionResult Save(EClassify classify)
        {
            int result = _classifyDataAccess.Save(classify);
            return new EmptyResult();
        }
        /// <summary>
        /// 
        /// </summary>
        public ActionResult Delete(int classifyId = 0)
        {
            int result = _classifyDataAccess.Delete(classifyId);
            return new EmptyResult();
        }
    }
}
